Port upstream PRs #554, #555, #544: require permission handler, add custom-tool kind, task_complete event#32
Merged
Conversation
…ustom-tool kind, task_complete event **BREAKING**: `:on-permission-request` is now required in session config. Upstream changes ported: - PR #554: Make `onPermissionRequest` required on session creation/resume. Removes 0-arity `create-session` and 2-arity `resume-session` (and their async variants). Adds explicit validation with clear error message. - PR #555: Add `:custom-tool` to `::permission-kind` spec for custom tool permission requests. - PR #544: Add `:copilot/session.task_complete` event type (additive only; agent/compaction RPC methods not ported as they are not in public SDK API). Also fixes `build-session-config` in helpers.clj to pass through `:on-permission-request` (caught during code review). All tests (85 tests, 253 assertions), examples (9/9), and docs validated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR ports three upstream Node.js SDK changes to the Clojure SDK, implementing a breaking change that requires permission handlers for all session operations. The primary change makes :on-permission-request a required parameter when creating or resuming sessions, aligning with the upstream SDK's API contract. Additionally, it adds support for custom-tool permissions and the task_complete event type.
Changes:
- BREAKING:
:on-permission-requestis now required in all session creation/resumption calls, enforced by specs and explicit validation - Added
:custom-toolpermission kind for SDK-registered custom tool invocations (upstream PR #555) - Added
:copilot/session.task_completeevent type (upstream PR #544) - Fixed critical bug in
helpers.cljwherebuild-session-configwas dropping the:on-permission-requesthandler
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/github/copilot_sdk/specs.clj | Moved :on-permission-request from opt-un to req-un in session config specs; added :custom-tool to permission-kind; added :copilot/session.task_complete event type |
| src/github/copilot_sdk/client.clj | Added explicit validation for required permission handler with helpful error messages; removed 0-arity create-session and 2-arity resume-session variants; updated all docstrings to mark handler as required |
| src/github/copilot_sdk.clj | Removed optional arity overloads from wrapper functions; updated with-session macro to require config parameter; comprehensive docstring updates |
| src/github/copilot_sdk/helpers.clj | Fixed build-session-config to pass through :on-permission-request (critical for query helpers); updated docstring examples |
| src/github/copilot_sdk/instrument.clj | Updated fdef specs to require config parameter (removed s/? optional markers) |
| test/github/copilot_sdk_test.clj | Updated spec validation tests to include required :on-permission-request handler |
| test/github/copilot_sdk/integration_test.clj | Updated all 50+ test cases; added comprehensive validation tests for missing handlers; added :custom-tool to permission kind tests |
| test/github/copilot_sdk/e2e_test.clj | Updated all E2E tests with required permission handlers |
| examples/*.clj | Updated all 10 example files to include :on-permission-request copilot/approve-all |
| examples/README.md | Updated all code snippets with permission handlers; revised permission model description |
| doc/getting-started.md | Updated all examples and tutorial code with required handlers |
| doc/reference/API.md | Comprehensive updates to API documentation marking handler as required; updated all code examples |
| README.md | Updated quick start examples with permission handlers |
| CHANGELOG.md | Well-structured changelog entry following Keep a Changelog conventions; clearly marked as BREAKING |
github-actions Bot
pushed a commit
that referenced
this pull request
Feb 26, 2026
…reference - Add :copilot/session.task_complete to Event Reference table in API.md - Add permission kind reference table listing all kinds (:shell, :write, :mcp, :read, :url, :custom-tool) in Permission Handling section - Update CHANGELOG.md [Unreleased] section Both were added in PR #32 (upstream PRs #544, #555) but were missing from the API reference documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Feb 26, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BREAKING:
:on-permission-requestis now required in session config maps forcreate-sessionandresume-session(and their async variants).This PR ports three upstream copilot-sdk changes:
PR #554 — Require
onPermissionRequeston session creation/resume:on-permission-requestmoved fromopt-untoreq-unin::session-configand::resume-session-configspecscreate-sessionand 2-arityresume-session(and async variants)with-sessionmacro to require config argumentPR #555 — Add
custom-toolpermission kind:custom-toolto::permission-kindspec for custom tool permission requestsPR #544 — Agent selection & compaction (partial)
:copilot/session.task_completeevent type (additive)agent.select,context.compact) — not exposed in public SDK APIBug fix (found during code review)
build-session-configinhelpers.cljto pass through:on-permission-request— without this,h/query,h/query-seq!, andh/query-chanwould silently drop the handler when creating sessions from option mapsVerification
Files changed (23)
specs.clj,client.clj,copilot_sdk.clj,helpers.clj,instrument.cljintegration_test.clj,e2e_test.clj,copilot_sdk_test.cljREADME.md,getting-started.md,API.md,examples/README.md,CHANGELOG.md